// 公共Mixin
import { isString } from '@/utils'
const common = {
	data() {
		// 冲突时以组件数据优先
		return {
			navigateFlag: false,
			inited: false
		}
	},
	// 同名钩子函数都调用，混入的在前
	created() {
		this.inited = true
	},
	// methods、components 和 directives 合并为一个，冲突时以组件优先
	methods: {
		router(params) {
			if (!params) return
			if (this.navigateFlag) return
			this.navigateFlag = true;
			if (isString(params)) {
				uni.navigateTo({
					url: params
				})
			} else {
				uni.navigateTo(params)
			}
			setTimeout(() => {
				this.navigateFlag = false;
			}, 200)
		}
	}
}

export default common
